﻿using System;
using System.Collections.Generic;
using System.Linq;
using uTrade.Common;

namespace uTrade.Core.Statistics
{
    public class ProfitStatistics
    {
        private Strategy TestStrategy;

        public TestResult TestResultShort = new TestResult();

        public TestResult TestResultLong = new TestResult();

        public TestResult TestResultAll = new TestResult();

        public List<TradeItem> TradeItems = new List<TradeItem>();

        public ProfitStatistics(Strategy strategy)
        {
            TestStrategy = strategy;
        }

        private List<Tuple<string, List<OrderItem>>> listCopy = new List<Tuple<string, List<OrderItem>>>();

        /// <summary>
        /// 取策略中的所有交易，并在最后添加平仓
        /// </summary>
        /// <returns></returns>
        private List<OrderItem> GetOrderItems()
        {
            List<OrderItem> orders = new List<OrderItem>();

            if (TestStrategy.Operations.Count > 0)
            {
                orders.AddRange(TestStrategy.Operations);

                // 在最后增加平仓
                if (TestStrategy.Operations.Last().Offset == Offset.Open)
                {
                    OrderItem tmp = new OrderItem();
                    if (TestStrategy.PositionLong > 0)
                    {
                        tmp.DateTiem = DateService.UTC2Datetime(TestStrategy.DateTimeUTC[0]);   //DateTime.ParseExact(TestStrategy.DateTimeUTC[0].ToString("00000000.000000"), "yyyyMMdd.HHmmss", null);
                        tmp.Dir = Direction.Sell;
                        tmp.Lots = TestStrategy.PositionLong;
                        tmp.Offset = Offset.Close;
                        tmp.Price = TestStrategy.Close[0];
                        orders.Add(tmp);
                    }
                    if (TestStrategy.PositionShort > 0)
                    {
                        tmp.DateTiem = DateService.UTC2Datetime(TestStrategy.DateTimeUTC[0]);   //DateTime.ParseExact(TestStrategy.Time[0].ToString("00000000.000000"), "yyyyMMdd.HHmmss", null);
                        tmp.Dir = Direction.Buy;
                        tmp.Lots = TestStrategy.PositionShort;
                        tmp.Offset = Offset.Close;
                        tmp.Price = TestStrategy.Close[0];
                        orders.Add(tmp);
                    }
                }
            }
            listCopy.Add(new Tuple<string, List<OrderItem>>(TestStrategy.Name, orders));

            return orders;
        }

        public void AnalysisAsync()
        {
            List<OrderItem> orderItems = GetOrderItems();

            int MaxConsecutiveProfit = 0;       // p最大连续盈利次数 = 0
            int MaxConsecutiveLosses = 0;       // p最大连续亏损次数 = 0
            int MaxConsecutiveProfitLong = 0;   // p最大连续盈利次数多 = 0
            int MaxConsecutiveLossesLong = 0;   // p最大连续亏损次数多 = 0
            int MaxConsecutiveProfitShort = 0;  // p最大连续盈利次数空 = 0
            int MaxConsecutiveLossesShort = 0;  // p最大连续亏损次数空 = 0
            for (int i = 0; i < orderItems.Count; i++)
            {
                if (orderItems[i].Offset != Offset.Open)
                {
                    //查找对应的开仓
                    if (orderItems[i].Dir == Direction.Sell) //卖平
                    {
                        for (int iOpen = 0; iOpen < orderItems.Count; iOpen++)
                        {
                            //查找对应的买开
                            if (orderItems[iOpen].Offset == Offset.Open && orderItems[iOpen].Dir == Direction.Buy)
                            {
                                int closeLots = Math.Min(orderItems[iOpen].Lots, orderItems[i].Lots);
                                orderItems[iOpen].Lots -= closeLots;
                                orderItems[i].Lots -= closeLots;
                                TradeItem tradeItem = new TradeItem();//DataRow drNew = this.dtOperation.NewRow();
                                //drNew["#"] = this.dtOperation.Rows.Count + 1;
                                //drNew["多空"] = "多
                                //drNew["开仓时间"] = orderItems[iOpen].Date;
                                //drNew["开仓价格"] = orderItems[iOpen].Price;
                                //drNew["平仓时间"] = orderItems[i].Date;
                                //drNew["平仓价格"] = orderItems[i].Price;
                                //drNew["手数"] = closeLots;
                                //drNew["手续费"] = closeLots * ((crate.Item1 > 1 ? crate.Item1 : (orderItems[iOpen].Price * crate.Item1) * procInfo.VolumeMultiple) + (crate.Item2 > 1 ? crate.Item2 : (operationCopy[i].Price * crate.Item2) * procInfo.VolumeMultiple));
                                //drNew["净利"] = (orderItems[i].Price - orderItems[iOpen].Price) * closeLots * procInfo.VolumeMultiple - (double)drNew["手续费"];
                                tradeItem.TradeType = TradeType.Long;
                                tradeItem.OpenDate = orderItems[iOpen].DateTiem;
                                tradeItem.OpenPrice = orderItems[iOpen].Price;
                                tradeItem.CloseDate = orderItems[i].DateTiem;
                                tradeItem.ClosePrice = orderItems[i].Price;
                                tradeItem.Lots = closeLots;
                                //tradeItem.Fee = closeLots * ((crate.Item1 > 1 ? crate.Item1 : (orderItems[iOpen].Price * crate.Item1) * procInfo.VolumeMultiple) + (crate.Item2 > 1 ? crate.Item2 : (operationCopy[i].Price * crate.Item2) * procInfo.VolumeMultiple));
                                //tradeItem.NetProfit = (orderItems[i].Price - orderItems[iOpen].Price) * closeLots * procInfo.VolumeMultiple - (double)drNew["手续费"];

                                TradeItem lastTrade = TradeItems.LastOrDefault();
                                tradeItem.TotalNetProfit = lastTrade == null ? tradeItem.NetProfit : lastTrade.TotalNetProfit + tradeItem.NetProfit;
                                //DataRow drLast = this.dtOperation.AsEnumerable().LastOrDefault();
                                //if (drLast == null)
                                //    drNew["净利合计"] = drNew["净利"];
                                //else
                                //    drNew["净利合计"] = (double)drLast["净利合计"] + (double)drNew["净利"];
                                //this.dtOperation.Rows.Add(drNew);
                                TradeItems.Add(tradeItem);
                                if (tradeItem.NetProfit > 0)
                                {
                                    MaxConsecutiveProfit++;   //p最大连续盈利次数++;
                                    MaxConsecutiveProfitLong++;  //p最大连续盈利次数多++;
                                    MaxConsecutiveLosses = MaxConsecutiveLossesShort = 0;   //p最大连续亏损次数 = p最大连续亏损次数多 = 0;

                                    TestResultLong.MaxConsecutiveProfit = Math.Max(TestResultLong.MaxConsecutiveProfit, MaxConsecutiveProfitLong);     //最大连续盈利次数多 = Math.Max(最大连续盈利次数多, p最大连续盈利次数多);
                                    TestResultAll.MaxConsecutiveProfit = Math.Max(TestResultLong.MaxConsecutiveProfit, TestResultAll.MaxConsecutiveProfit);    //最大连续盈利次数 = Math.Max(最大连续盈利次数, 最大连续盈利次数多);
                                }
                                else
                                {
                                    MaxConsecutiveLosses++;         //p最大连续亏损次数++;
                                    MaxConsecutiveLossesLong++;     //p最大连续亏损次数多++;
                                    MaxConsecutiveProfit = MaxConsecutiveProfitLong = 0;    //p最大连续盈利次数 = p最大连续盈利次数多 = 0;

                                    TestResultLong.MaxConsecutiveLosses = Math.Max(TestResultLong.MaxConsecutiveLosses, MaxConsecutiveLossesLong);//最大连续亏损次数多 = Math.Max(最大连续亏损次数多, p最大连续亏损次数多);
                                    TestResultAll.MaxConsecutiveLosses = Math.Max(TestResultAll.MaxConsecutiveLosses, TestResultLong.MaxConsecutiveLosses);//最大连续亏损次数 = Math.Max(最大连续亏损次数, 最大连续亏损次数多);
                                }

                                if (orderItems[iOpen].Lots == 0)
                                {
                                    orderItems.RemoveAt(iOpen);
                                    iOpen--;
                                    i--;
                                }
                                if (orderItems[i].Lots == 0)
                                {
                                    orderItems.RemoveAt(i);
                                    iOpen--;
                                    i--;
                                    break;
                                }
                            }
                        }
                    }
                    else
                    {
                        for (int iOpen = 0; iOpen < orderItems.Count; iOpen++)   //BP
                        {
                            if (orderItems[iOpen].Offset == Offset.Open && orderItems[iOpen].Dir == Direction.Sell)
                            {
                                int closeLots = Math.Min(orderItems[iOpen].Lots, orderItems[i].Lots);
                                orderItems[iOpen].Lots -= closeLots;
                                orderItems[i].Lots -= closeLots;
                                TradeItem tradeItem = new TradeItem();//DataRow drNew = this.dtOperation.NewRow();
                                //drNew["#"] = this.dtOperation.Rows.Count + 1;
                                //drNew["多空"] = "空
                                //drNew["开仓时间"] = orderItems[iOpen].Date;
                                //drNew["开仓价格"] = orderItems[iOpen].Price;
                                //drNew["平仓时间"] = orderItems[i].Date;
                                //drNew["平仓价格"] = orderItems[i].Price;
                                //drNew["手数"] = closeLots;
                                //drNew["手续费"] = closeLots * ((crate.Item1 > 1 ? crate.Item1 : (orderItems[iOpen].Price * crate.Item1 * procInfo.VolumeMultiple)) + (crate.Item2 > 1 ? crate.Item2 : (operationCopy[i].Price * crate.Item2 * procInfo.VolumeMultiple)));
                                //drNew["净利"] = -(orderItems[i].Price - operationCopy[iOpen].Price) * closeLots * procInfo.VolumeMultiple - (double)drNew["手续费"];

                                tradeItem.TradeType = TradeType.Short;
                                tradeItem.OpenDate = orderItems[iOpen].DateTiem;
                                tradeItem.OpenPrice = orderItems[iOpen].Price;
                                tradeItem.CloseDate = orderItems[i].DateTiem;
                                tradeItem.ClosePrice = orderItems[i].Price;
                                tradeItem.Lots = closeLots;
                                //tradeItem.Fee = closeLots * ((crate.Item1 > 1 ? crate.Item1 : (orderItems[iOpen].Price * crate.Item1 * procInfo.VolumeMultiple)) + (crate.Item2 > 1 ? crate.Item2 : (operationCopy[i].Price * crate.Item2 * procInfo.VolumeMultiple)));
                                //tradeItem.NetProfit = -(orderItems[i].Price - operationCopy[iOpen].Price) * closeLots * procInfo.VolumeMultiple - (double)drNew["手续费"];
                                //DataRow drLast = this.dtOperation.AsEnumerable().LastOrDefault();
                                //if (drLast == null)
                                //    drNew["净利合计"] = drNew["净利"];
                                //else
                                //    drNew["净利合计"] = (double)drLast["净利合计"] + (double)drNew["净利"];
                                //this.dtOperation.Rows.Add(drNew);
                                TradeItem lastTrade = TradeItems.LastOrDefault();
                                tradeItem.TotalNetProfit = lastTrade == null ? tradeItem.NetProfit : lastTrade.TotalNetProfit + tradeItem.NetProfit;
                                if (tradeItem.NetProfit > 0)
                                {
                                    MaxConsecutiveProfit++;         //p最大连续盈利次数++;
                                    MaxConsecutiveProfitShort++;    //p最大连续盈利次数空++;
                                    MaxConsecutiveLosses = MaxConsecutiveLossesShort = 0;   //p最大连续亏损次数 = p最大连续亏损次数空 = 0;

                                    TestResultShort.MaxConsecutiveProfit = Math.Max(TestResultShort.MaxConsecutiveProfit, MaxConsecutiveProfitShort);           //最大连续盈利次数空 = Math.Max(最大连续盈利次数空, p最大连续盈利次数空);
                                    TestResultAll.MaxConsecutiveProfit = Math.Max(TestResultAll.MaxConsecutiveProfit, TestResultShort.MaxConsecutiveProfit);    //最大连续盈利次数 = Math.Max(最大连续盈利次数, 最大连续盈利次数空);
                                }
                                else
                                {
                                    MaxConsecutiveLosses++;     //p最大连续亏损次数++;
                                    MaxConsecutiveLossesShort++;//p最大连续亏损次数空++;
                                    MaxConsecutiveProfit = MaxConsecutiveProfitShort = 0;   //p最大连续盈利次数 = p最大连续盈利次数空 = 0;

                                    TestResultShort.MaxConsecutiveLosses = Math.Max(TestResultShort.MaxConsecutiveLosses, MaxConsecutiveLossesShort);   //最大连续亏损次数空 = Math.Max(最大连续亏损次数空, p最大连续亏损次数空);
                                    TestResultAll.MaxConsecutiveLosses = Math.Max(TestResultAll.MaxConsecutiveLosses, TestResultShort.MaxConsecutiveLosses);    //最大连续亏损次数 = Math.Max(最大连续亏损次数, 最大连续亏损次数空);
                                }
                                if (orderItems[iOpen].Lots == 0)
                                {
                                    orderItems.RemoveAt(iOpen);
                                    iOpen--;
                                    i--;
                                }
                                if (orderItems[i].Lots == 0)
                                {
                                    orderItems.RemoveAt(i);
                                    iOpen--;
                                    i--;
                                    break;
                                }
                            }
                        }
                    }
                }
            }

            var drsLong = TradeItems.Where(n => n.TradeType == TradeType.Long);
            var drsShort = TradeItems.Where(n => n.TradeType == TradeType.Short);

            TestResultAll.NetProfit = TradeItems.Last().TotalNetProfit;
            TestResultLong.NetProfit = drsLong.Count() == 0 ? 0 : drsLong.Sum(n => n.NetProfit);
            TestResultShort.NetProfit = drsShort.Count() == 0 ? 0 : drsShort.Sum(n => n.NetProfit);

            // 总盈利
            TestResultLong.TotalProfit = drsLong.Count() == 0 ? 0 : drsLong.Where(n => n.NetProfit > 0).Sum(n => n.NetProfit);
            TestResultShort.TotalProfit = drsShort.Count() == 0 ? 0 : drsShort.Where(n => n.NetProfit > 0).Sum(n => n.NetProfit);
            TestResultAll.TotalProfit = TestResultLong.TotalProfit + TestResultShort.TotalProfit;

            // 总亏损
            TestResultLong.TotalLoss = drsLong.Count() == 0 ? 0 : drsLong.Where(n => n.NetProfit < 0).Sum(n => n.NetProfit);
            TestResultShort.TotalLoss = drsShort.Count() == 0 ? 0 : drsShort.Where(n => n.NetProfit < 0).Sum(n => n.NetProfit);
            TestResultAll.TotalLoss = TestResultLong.TotalLoss + TestResultShort.TotalLoss;

            //// 总盈利/总亏损
            //TestResultLong.Value = Math.Abs(总盈利多 / 总亏损多);
            //TestResultShort.Value = Math.Abs(总盈利空 / 总亏损空);
            //TestResultAll.Value = Math.Abs((总盈利多 + 总盈利空) / (总亏损多 + 总亏损空));

            // 交易手数
            TestResultLong.LotsNumber = drsLong.Count() == 0 ? 0 : drsLong.Sum(n => n.Lots);
            TestResultShort.LotsNumber = drsShort.Count() == 0 ? 0 : drsShort.Sum(n => n.Lots);
            TestResultAll.LotsNumber = TestResultLong.LotsNumber + TestResultShort.LotsNumber;

            // 盈利比率
            // 盈利手数
            TestResultLong.ProfitLot = drsLong.Count() == 0 ? 0 : drsLong.Where(n => n.NetProfit > 0).Sum(n => n.Lots);
            //TestResultLong.Value = TestResultLong.LotsNumber == 0 ? 0 : 盈利手数多 / 手数多;
            TestResultShort.ProfitLot = drsShort.Count() == 0 ? 0 : drsShort.Where(n => n.NetProfit > 0).Sum(n => n.Lots);
            //TestResultShort.Value = TestResultShort.LotsNumber == 0 ? 0 : 盈利手数空 / 手数空;
            TestResultAll.ProfitLot = TestResultLong.ProfitLot + TestResultShort.ProfitLot;

            //TestResultLong.Value = 盈利手数多;
            //TestResultShort.Value = 盈利手数空;
            //TestResultAll.Value = 盈利手数多 + 盈利手数空;

            // 亏损手数
            TestResultLong.LossLot = drsLong.Count() == 0 ? 0 : drsLong.Where(n => (double)n.NetProfit < 0).Sum(n => (int)n.Lots);
            TestResultShort.LossLot = drsShort.Count() == 0 ? 0 : drsShort.Where(n => (double)n.NetProfit < 0).Sum(n => (int)n.Lots);
            TestResultAll.LossLot = TestResultLong.LossLot + TestResultShort.LossLot;

            // 持平手数
            TestResultLong.DrawsLots = TestResultLong.LotsNumber - TestResultLong.LossLot - TestResultLong.ProfitLot;
            TestResultShort.DrawsLots = TestResultShort.LotsNumber - TestResultShort.LossLot - TestResultShort.ProfitLot;
            TestResultAll.DrawsLots = TestResultLong.DrawsLots + TestResultShort.DrawsLots;

            // 平均利润
            TestResultLong.AvgProfit = TestResultLong.LotsNumber == 0 ? 0 : TestResultLong.NetProfit / TestResultLong.LotsNumber;
            TestResultShort.AvgProfit = TestResultShort.LotsNumber == 0 ? 0 : TestResultShort.NetProfit / TestResultShort.LotsNumber;
            TestResultAll.AvgProfit = TestResultAll.NetProfit / TestResultAll.LotsNumber;

            // 平均盈利
            TestResultLong.AvgProfit = TestResultLong.LotsNumber == 0 ? 0 : TestResultLong.TotalProfit / TestResultLong.ProfitLot;
            TestResultShort.AvgProfit = TestResultShort.LotsNumber == 0 ? 0 : TestResultShort.TotalProfit / TestResultShort.ProfitLot;
            TestResultAll.AvgProfit = (TestResultLong.TotalProfit + TestResultShort.TotalProfit) / (TestResultLong.ProfitLot + TestResultShort.ProfitLot);   //(总盈利多 + 总盈利空) / (盈利手数多 + 盈利手数空);

            // 平均亏损
            TestResultLong.AvgLoss = TestResultLong.LotsNumber == 0 ? 0 : TestResultLong.TotalLoss / TestResultLong.LossLot;
            TestResultShort.AvgLoss = TestResultShort.LotsNumber == 0 ? 0 : TestResultShort.TotalLoss / TestResultShort.LossLot;
            TestResultAll.AvgLoss = (TestResultLong.TotalLoss + TestResultShort.TotalLoss) / (TestResultLong.LossLot + TestResultShort.LossLot);//(总亏损多 + 总亏损空) / (亏损手数多 + 亏损手数空);

            // 平均盈利/平均亏损
            //TestResultLong.Value = TestResultLong.LotsNumber == 0 ? 0 : (总盈利多 / 盈利手数多) / (总亏损多 / 亏损手数多);
            //TestResultShort.Value = TestResultShort.LotsNumber == 0 ? 0 : (总盈利空 / 盈利手数空) / (总亏损空 / 亏损手数空);
            //TestResultAll.Value = ((总盈利多 + 总盈利空) / (盈利手数多 + 盈利手数空)) / ((总亏损多 + 总亏损空) / (亏损手数多 + 亏损手数空));

            // 最大盈利
            double 最大盈利多 = drsLong.Count() == 0 ? 0 : drsLong.Max(n => (double)n.NetProfit);
            最大盈利多 = Math.Max(0, 最大盈利多);
            TestResultLong.MaxProfit = 最大盈利多;
            double 最大盈利空 = drsShort.Count() == 0 ? 0 : drsShort.Max(n => (double)n.NetProfit);
            最大盈利空 = Math.Max(0, 最大盈利空);
            TestResultShort.MaxProfit = 最大盈利空;
            TestResultAll.MaxProfit = Math.Max(最大盈利多, 最大盈利空);

            // 最大亏损
            double 最大亏损多 = drsLong.Count() == 0 ? 0 : drsLong.Min(n => (double)n.NetProfit);
            TestResultLong.MaxLoss = 最大亏损多;
            double 最大亏损空 = drsShort.Count() == 0 ? 0 : drsShort.Min(n => (double)n.NetProfit);
            TestResultShort.MaxLoss = 最大亏损空;
            TestResultAll.MaxLoss = Math.Min(最大亏损多, 最大亏损空);

            // 最大盈利/总盈利
            //TestResultLong.Value = 最大盈利多 / 总盈利多;
            //TestResultShort.Value = 最大盈利空 / 总盈利空;
            //TestResultAll.Value = Math.Max(最大盈利多, 最大盈利空) / (总盈利多 + 总盈利空);

            // 最大亏损/总亏损
            //TestResultLong.Value = 最大亏损多 / 总亏损多;
            //TestResultShort.Value = 最大亏损空 / 总亏损空;
            //TestResultAll.Value = Math.Min(最大亏损多, 最大亏损空) / (总亏损多 + 总亏损空);

            // 净利润/最大亏损
            //TestResultLong.Value = 净利润多 / -最大亏损多;
            //TestResultShort.Value = 净利润空 / -最大亏损空;
            //TestResultAll.Value = 净利润 / -Math.Min(最大亏损多, 最大亏损空);

            // 最大连续盈利次数
            //TestResultLong.Value = 最大连续盈利次数多;
            //TestResultShort.Value = 最大连续盈利次数空;
            //TestResultAll.Value = 最大连续盈利次数;

            // 最大连续亏损次数
            //TestResultLong.Value = 最大连续亏损次数多;
            //TestResultShort.Value = 最大连续亏损次数空;
            //TestResultAll.Value = 最大连续亏损次数;

            // 最大保证金占用
            //TestResultLong.MaxMarginOccupation = maxMarginLong;// 0;// _stra.MaxMarginLong * crate.Item4;
            //TestResultShort.MaxMarginOccupation = maxMarginShort;// 0;// ws.DicStrategys[this.toolStripComboBoxStrategy.Text].MaxMarginShort * crate.Item5;
            //double 最大保证金占用 = Math.Max(maxMarginLong, maxMarginShort);// Math.Max(double.Parse(TestResultLong.Value.ToString()), double.Parse(TestResultShort.Value.ToString()));
            //TestResultAll.MaxMarginOccupation = 最大保证金占用;

            // 佣金合计
            TestResultLong.TotalCommission = drsLong.Count() == 0 ? 0 : drsLong.Sum(n => (double)n.Fee);
            TestResultShort.TotalCommission = drsShort.Count() == 0 ? 0 : drsShort.Sum(n => (double)n.Fee);
            TestResultAll.TotalCommission = (double)TestResultLong.TotalCommission + (double)TestResultShort.TotalCommission;

            //TimeSpan diff = DateTime.ParseExact(_stra.D[0].ToString("00000000.000000"), "yyyyMMdd.HHmmss", null) - DateTime.ParseExact(_stra.D.First().ToString("00000000.000000"), "yyyyMMdd.HHmmss", null);// (ws.DicStrategys[this.toolStripComboBoxStrategy.Text].D[0] - ws.DicStrategys[this.toolStripComboBoxStrategy.Text].D[ws.DicStrategys[this.toolStripComboBoxStrategy.Text].CurrentBar]);

            // 收益率(最大保证金)
            TestResultAll.Yield = TestResultAll.NetProfit / TestResultAll.MaxMarginOccupation;    //净利润 / 最大保证金占用;
            TestResultLong.Yield = double.NaN;
            TestResultShort.Yield = double.NaN;

            // 年度收益率（最大保证金）
            //TestResultAll.AnnualReturnRate = TestResultAll.NetProfit / diff.Days * 360 / TestResultAll.MaxMarginOccupation;   //净利润 / diff.Days * 360 / 最大保证金占用;

            TestResultLong.AnnualReturnRate = double.NaN;
            TestResultShort.AnnualReturnRate = double.NaN;

            // 月度平均盈利
            //TestResultAll.AvgMonthlyProfit = TestResultAll.NetProfit / diff.Days * 30;  //净利润 / diff.Days * 30;
            TestResultLong.AvgMonthlyProfit = double.NaN;
            TestResultShort.AvgMonthlyProfit = double.NaN;

            //for (int i = ws.dt.Count - 1; i >= 0; i--)
            //{
            //	maxEquity = Math.Max(maxEquity, ws.DicStrategys[this.toolStripComboBoxStrategy.Text].Series["@equity"][i]);
            //	if (maxEquity - ws.DicStrategys[this.toolStripComboBoxStrategy.Text].Series["@equity"][i] > maxReturn)
            //	{
            //		maxReturn = maxEquity - ws.DicStrategys[this.toolStripComboBoxStrategy.Text].Series["@equity"][i];
            //		dtMaxReturn = ws.dt[i];
            //		maxRate = maxReturn / maxEquity;
            //	}
            //}

            // 最大回撤
            //TestResultAll.MaxWithdrawal = - maxReturn;
            TestResultLong.MaxWithdrawal = double.NaN;
            TestResultShort.MaxWithdrawal = double.NaN;

            // 发生时间
            //TestResultAll.Value = dtMaxReturn;
            //TestResultLong.Value = "
            //TestResultShort.Value = "

            // 回撤/前期高点
            //TestResultAll.Value = maxRate;
            //TestResultLong.Value = "
            //TestResultShort.Value = "
        }

        public List<TradeItem> GetTradeItems()
        {
            List<TradeItem> tradeItems = new List<TradeItem>();

            return tradeItems;
        }
    }
}